package design.structural.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zxs
 * @since 2020/05/22
 */
public class Composite implements Component {

    List<Component> childList = new ArrayList<>();

    @Override
    public void add(Component child){
        childList.add(child);
    }

    @Override
    public void remove(Component child){
        childList.remove(child);
    }

    public void doSomething(){
        for(Component c: childList){
            c.doSomething();
        }
    }
}
